/*
 * @Author: sunzhijun 
 * @Date: 2020-02-28 21:36:16 
 * @Last Modified by: sunzhijun
 * @Last Modified time: 2020-03-26 10:21:05
 */


export default class ButtonAction {
    constructor(comp) {
        this.comp = comp;
    }

    // 来自审批中心初始化button
    fromApproveInitButtonStatus = ()=>{
        const { props } = this.comp;
        const { button } = props;
        button.setButtonVisible({
            edit: true,
            save: false,
            cancel: false,
            print: false,
            output: false,
            file: true
        })
    }

    //初始化button
    initButtonStatus = ()=>{
        const { props } = this.comp;
        const { button } = props;
        button.setButtonVisible({
            edit: false,
            save: false,
            cancel: false,
            file: false
        })
    }

    //组织为空时button
    noneOrgButtonStatus = ()=>{
        const { props } = this.comp;
        const { button } = props;
        button.setButtonVisible({
            add: false,
            submit: false,
            revoke: false,
            delete: false,
            history: false,
            publicecity: false,
            refresh: false,
            save: false,
            cancel: false,
            export_excel: false,
            query: false,
            edit: false,
            print: false,
            cardview: false,
            file: false
        })
    }

    //选择组织后button
    orgButtonStatus = ()=>{
        const { props } = this.comp;
        const { button } = props;
        button.setButtonVisible({
            add: true,
            submit: true,
            revoke: true,
            delete: true,
            history: false,
            publicecity: true,
            refresh: true,
            save: false,
            cancel: false,
            query: true,
            export_excel: true,
            edit: false,
            print: true,
            cardview: false,
            file: false
        })
    }

    // 编辑态button
    editButtonStatus = ()=>{
        const {props} = this.comp;
        const {button, main} = props;
        button.setButtonVisible({
            save: true,
            cancel: true,
            edit: false,
            query: false,
            add: false,
            submit: false,
            revoke: false,
            delete: false,
            history: false,
            publicecity: false,
            refresh: false,
            export_excel: false,
            cardview: false,
            file: false
        })
    }
    //取消编辑态
    cancelEditBUttonStatus = ()=>{
        const {props} = this.comp;
        const {button, main} = props;
        button.setButtonVisible({
            save: false,
            cancel: false,
            cardview: true,
            file: true
        })
    }

    //列表和卡片按钮显示状态
    buttonStatus = ()=>{
        const {props} = this.comp;
        const {button, main} = props;
        let { isCardForm } = main;
        button.setButtonVisible({
           print: isCardForm ? false : true
        })
    }

    // 按钮点击回调-主按钮区
    headerClick = (props, btnCode) => {
        const {action} = this.comp;
        switch (btnCode) {
            case 'add': 
                action.headerAct.newAddAction();
                break;
            case 'query':
                action.headerAct.query();
                break;
            case 'edit':
                action.headerAct.editAction();
                break;
            case 'save':
                action.headerAct.saveAction();
                break;
            case 'cancel':
                action.headerAct.cancelAction();
                break;
            case 'history':
                action.headerAct.historyAction();
                break;
            case 'revoke':
                action.headerAct.revokeAction();
                break;
            case 'delete':
                action.headerAct.deleteAction();
                break;
            case 'publicecity':
                action.headerAct.publicecityAction();
                break;
            case 'refresh':
                action.headerAct.refreshAction();
                break;
            case 'submit':
                action.headerAct.submitAction();
                break;
            case 'export_excel':
                action.headerAct.export_excelAction();
                break;
            case 'print':
                action.headerAct.printAction();
                break;
            case 'output':
                action.headerAct.outputAction();
                break;
            case 'cardview':
                action.headerAct.showCardview();
            case 'file':
                action.headerAct.FileManagement();
                break;
            default:
                break;
        }
    }
}